unit RaMD5;

interface

uses
  SysUtils, Classes, Windows, MD5Real, stdctrls, Controls;

type
  TRaMD5 = class(TComponent)
  private
    fOS: string;
    fMd5C: string;
    fOwner: TWinControl;
    fAuthor: string;
    fOnOSChange: TNotifyEvent;
    procedure SetAuthor(Value: string);
  protected
    procedure pOSChange(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
    function MD5Code: string;
  published
    property OriginalString: string read fOS write fOS stored false;
    property Author: string read fAuthor write SetAuthor;
    property MD5CodeResult: string read fMd5C;
    property OnOSChange: TNotifyEvent read fOnOSChange write fOnOSChange;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Rarnu Components', [TRaMD5]);
end;

{ TRaMD5 }

constructor TRaMD5.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  fOwner := TWinControl(AOwner);
  OnOSChange := pOSChange;
  fAuthor := 'Rarnu -- http://rarnu.ik8.com';
end;

function TRaMD5.MD5Code: string;
begin
  result := MD5Real.RivestStr(OriginalString);
end;

procedure TRaMD5.pOSChange(Sender: TObject);
begin
  if Assigned(OnOSChange) then
    fMd5C := MD5Real.RivestStr(OriginalString);
end;

procedure TRaMD5.SetAuthor(Value: string);
begin
  fAuthor := 'Rarnu -- http://rarnu.ik8.com';
end;

end.

